package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.LbsTerminalState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-08-08 09:47:28
 */
@Repository
public class LbsTerminalStateDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(LbsTerminalStateDao.class);

    public LbsTerminalState insert(final LbsTerminalState lbsTerminalState) {
        insert("LbsTerminalState.insert", lbsTerminalState);
        return lbsTerminalState;
    }

    public Boolean updateInfoById(final LbsTerminalState lbsTerminalState) {
        return update("LbsTerminalState.updateInfoById", lbsTerminalState) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("LbsTerminalState.updateInfoByQuery", query) > 0;
    }

    public LbsTerminalState selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("LbsTerminalState.selectById", query);
    }

    public List<LbsTerminalState> selectByQuery(final Query query) {
        return queryForList("LbsTerminalState.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("LbsTerminalState.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        LbsTerminalState lbsTerminalState = new LbsTerminalState();
        lbsTerminalState.setDeleteFlag(1);
        lbsTerminalState.setId(id);
        lbsTerminalState.setEntId(entId);

        return update("LbsTerminalState.updateInfoById", lbsTerminalState) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("LbsTerminalState.deleteById", query) > 0;
    }
}